/*
 * Copyright 2012 ITC Tsinghua University. All Rights Reserved.
 */
package cn.edu.tsinghua.cic.ccss.dto;

import java.util.Date;

import org.forten.core.dto.GeneralDto;

/**
 * 
 * 
 * @author <a href="mailto:du_yi@bbn.cn">Duyi</a>
 * 
 * @since 2012-5-14
 */
public class CourseSelectionDto implements GeneralDto,
		Comparable<CourseSelectionDto> {
	private static final long serialVersionUID = 1627324679823389859L;

	private long id;// Id
	private long courseId;// 课程ID
	private long cadreId;// 干部ID
	private Date selectTime;// 选课操作时间
	private String selectCardId;// 选课操作人工作证号
	private String state;// 上课状态
	private String stateExplanation;// 上课状态说明
	private String memo;// 备注
	private boolean allowCancel;
	private boolean allowLeave;
	private String resultOfShortMsgSign;
	private CourseDto courseDto;
	private CadreDto cadreDto;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getCourseId() {
		return courseId;
	}

	public void setCourseId(long courseId) {
		this.courseId = courseId;
	}

	public long getCadreId() {
		return cadreId;
	}

	public void setCadreId(long cadreId) {
		this.cadreId = cadreId;
	}

	public Date getSelectTime() {
		return selectTime;
	}

	public void setSelectTime(Date selectTime) {
		this.selectTime = selectTime;
	}

	public String getSelectCardId() {
		return selectCardId;
	}

	public void setSelectCardId(String selectCardId) {
		this.selectCardId = selectCardId;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getStateExplanation() {
		return stateExplanation;
	}

	public void setStateExplanation(String stateExplanation) {
		this.stateExplanation = stateExplanation;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	
	public String getResultOfShortMsgSign() {
		return resultOfShortMsgSign;
	}

	public void setResultOfShortMsgSign(String resultOfShortMsgSign) {
		this.resultOfShortMsgSign = resultOfShortMsgSign;
	}

	/**
	 * @return the courseDto
	 */
	public CourseDto getCourseDto() {
		return courseDto;
	}

	/**
	 * @param courseDto
	 *            the courseDto to set
	 */
	public void setCourseDto(CourseDto courseDto) {
		this.courseDto = courseDto;
	}

	/**
	 * @return the cadreDto
	 */
	public CadreDto getCadreDto() {
		return cadreDto;
	}

	/**
	 * @param cadreDto
	 *            the cadreDto to set
	 */
	public void setCadreDto(CadreDto cadreDto) {
		this.cadreDto = cadreDto;
	}

	public boolean isAllowCancel() {
		return allowCancel;
	}

	public void setAllowCancel(boolean allowCancel) {
		this.allowCancel = allowCancel;
	}

	public boolean isAllowLeave() {
		return allowLeave;
	}

	public void setAllowLeave(boolean allowLeave) {
		this.allowLeave = allowLeave;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "CourseSelectionDto [id=" + id + ", courseId=" + courseId
				+ ", cadreId=" + cadreId + ", selectTime=" + selectTime
				+ ", selectCardId=" + selectCardId + ", state=" + state
				+ ", stateExplanation=" + stateExplanation + ", memo=" + memo
				+ ", courseDto=" + courseDto + ", cadreDto=" + cadreDto + "]";
	}

	@Override
	public int compareTo(CourseSelectionDto that) {

		int flag = 0;
		if (this.courseDto.getNum().compareTo(that.getCourseDto().getNum()) == 0) {
			if (this.cadreDto.getCardNum().compareTo(
					that.getCadreDto().getCardNum()) == 0) {
				flag = 0;
			} else if (this.cadreDto.getCardNum().compareTo(
					that.getCadreDto().getCardNum()) > 0) {
				flag = 1;
			} else if (this.cadreDto.getCardNum().compareTo(
					that.getCadreDto().getCardNum()) < 0) {
				flag = -1;
			}
		} else if (this.courseDto.getNum().compareTo(
				that.getCourseDto().getNum()) > 0) {
			flag = 1;
		} else if (this.courseDto.getNum().compareTo(
				that.getCourseDto().getNum()) < 0) {
			flag = -1;
		}
		return flag;
	}
}
